package com.hs.jhzd.service.task;

import com.hs.jhzd.entity.SystemNotice;
import com.hs.jhzd.service.message.NoticeProducer;
import com.hs.jhzd.service.message.RoutingkeyEnums;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

@Data
public class ShiftStartTask implements Runnable {

  private NoticeProducer noticeProducer;

  private Map<String, Object> taskParam;

  @Override
  public void run() {

    SystemNotice systemNotice = new SystemNotice();
    Map<String, Object> param = new HashMap<>();
    systemNotice.setOrder(SystemNotice.ORDER_SHIFT_START);
    systemNotice.setParam(param);

    String dormCodesStr =null;

    if (StringUtils.isBlank(dormCodesStr)) {
      noticeProducer.sendMessage(RoutingkeyEnums.TERMINAL_ALL.getName(), systemNotice);
    } else {
      for (String dormCode : dormCodesStr.split(",")) {
        noticeProducer.sendMessage(RoutingkeyEnums.TERMINAL.getName() + dormCode, systemNotice);
      }
    }
  }

}

